#include <head.h>

int main(int argc, char const *argv[])
{
    int fd =open("hello.txt",O_CREAT | O_RDWR,0666);
    int fd_T=open("T.txt",O_CREAT | O_RDWR,0666);

    char buff[32]="B";

    int i=10;
    int T_NUM=0;
    flock(fd,LOCK_EX);
    read(fd_T,&T_NUM,sizeof(int));
    lseek(fd,T_NUM,SEEK_SET);
    while (i--)
    {
        sleep(1);
        write(fd,buff,1);
    }
    T_NUM=lseek(fd,0,SEEK_CUR);
    lseek(fd_T,0,SEEK_SET);
    write(fd_T,&T_NUM,sizeof(int));
    flock(fd,LOCK_UN);

    close(fd);
    close(fd_T);





    return 0;
}

